<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2018/11/5
 * Time: 14:02
 */

namespace Professor\Model;

use Common\Model\CommonModel;

class ProfessorModel extends CommonModel {

    const PF_STATUS_WAIT_VERIFY     = 0;
    const PF_STATUS_NORMAL          = 1;
    const PF_STATUS_FIBIDDEN        = 2;

    //自动验证
    protected $_validate = array(
        //array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
    );


    // 获取专栏作者基本信息
    public function getPfInfo($user_id = 0)
    {
        $pf_info = $this->where(['user_id' => $user_id, 'del_time' => 0])->find();
        if ($pf_info) {

            if ($pf_info['city_id']) {
                $city_info = M('area')->where(['id' => $pf_info['city_id']])->find();
                $pf_info['city_name'] = $city_info['areaname'];
            }

            $re = array(
                'status'        => true,
                'pf_info'       => $pf_info,
            );
            return $re;

        } else {
            $re = array(
              'status'      => false,
              'msg'         => '非专栏作者',
            );
            return $re;
        }
    }
}